package wangn.adt.lrparsing;

import java.util.*;

public class InnerNode {
    private Map<Character,LeafNode> childMap = new HashMap<>();

    public LeafNode getChild(char transferChar){
        return childMap.getOrDefault(transferChar,null);
    }

    /**
     *
     * @param transferChar LR1分析表的一列的名字
     * @param isTransfer TRUE：移动 FALSE：规约
     * @param state 移动就是下一个状态，否则是规约对应的产生式序号
     */
    public void addChild(char transferChar, boolean isTransfer, int state){
        childMap.put(transferChar,new LeafNode(isTransfer,state));
    }

    public boolean hasTransferChar(char transferChar){return childMap.containsKey(transferChar);}

    public Character[] getChildren(){
        return childMap.keySet().toArray(new Character[]{});
    }
}
